<%--
  Created by IntelliJ IDEA.
  User: 陈豪
  Date: 2025/7/25
  Time: 13:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <base href="<%= basePath %>"/>
    <title>茶叶进销存系统 - 仓库详情</title>
    <link rel="stylesheet" href="css/global.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
    <style>
        #top th{
            text-align: center;
        }
        .el-button {
            padding: 10px 20px;
            border-radius: 4px;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.3s;
            border: 1px solid;
            font-weight: 200;
        }
    </style>
</head>
<body>
<div class="app-container">
    <!-- 引入侧边栏组件 -->
    <div class="sidebar" id="sidebar">
        <div class="sidebar-logo" onclick="toggleSidebar()">
            <span><i class="fas fa-leaf tea-icon"></i> 茶叶进销存系统</span>
        </div>

        <div class="sidebar-menu">
            <div
                    class="menu-item "
                    onclick="location.href='views/home.jsp'"
            >
                <i class="fas fa-home"></i>
                <span>系统首页</span>
            </div>
            <div class="menu-item" onclick="location.href='TeaServlet'">
                <i class="fas fa-coffee"></i>
                <span>茶叶管理</span>
            </div>
            <div class="menu-item" onclick="location.href='CategoryServlet'">
                <i class="fas fa-tags"></i>
                <span>分类管理</span>
            </div>
            <div class="menu-item active" onclick="location.href='WarehouseServlet'">
                <i class="fas fa-boxes"></i>
                <span>仓库管理</span>
            </div>
            <div class="menu-item " onclick="location.href='OrderServlet'">
                <i class="fas fa-receipt"></i>
                <span>订单管理</span>
            </div>
            <div class="menu-item" onclick="location.href='LogisticsServlet'">
                <i class="fas fa-shipping-fast"></i>
                <span>物流管理</span>
            </div>
            <div class="menu-item" onclick="location.href='SupplierServlet'">
                <i class="fas fa-truck"></i>
                <span>供应商管理</span>
            </div>
            <div class="menu-item" onclick="location.href='<%=basePath%>purchase/list'">
                <i class="fas fa-truck"></i>
                <span>采购管理</span>
            </div>
            <div class="menu-item" onclick="location.href='CustomerServlet'">
                <i class="fas fa-users"></i>
                <span>客户管理</span>
            </div>
            <div class="menu-item" onclick="location.href='AddressServlet'">
                <i class="fas fa-map-marker-alt"></i>
                <span>地址管理</span>
            </div>
        </div>
    </div>

    <!-- 主内容区 -->
    <div class="main-content">
        <!-- 顶部导航栏 -->
        <div class="navbar">
            <div class="navbar-left">
                <h3><i class="fas fa-warehouse tea-icon"></i> 仓库详情</h3>
            </div>
            <div class="navbar-right">
                <span><i class="fas fa-user tea-icon"></i> 欢迎，${admin.name}</span>
                <a href="logout" class="el-link el-link--danger ml-10"><i class="fas fa-sign-out-alt"></i> 退出</a>
            </div>
        </div>

        <!-- 内容卡片 -->
        <div class="el-card fade-in">
            <div class="el-card__header">
                <span><i class="fas fa-list tea-icon"></i> 库存列表</span>
                <div>
                    <form method="post" action="WarehouseDetailServlet" style="display: inline-block;">
                        <input type="hidden" name="method" value="search">
                        <input type="text" name="Detailname" value="${Detailname}" class="el-input__inner" placeholder="请输入茶叶名称" style="width: 250px;">
                        <button type="submit" class="el-button el-button--primary" style="margin-left: 10px;">
                            <i class="fas fa-search"></i> 搜索
                        </button>
                    </form>
<%--                    <button class="el-button el-button--success" onclick="location.href='AddWarehouseServlet'" style="margin-left: 10px;">--%>
<%--                        <i class="fas fa-plus"></i> 新增库存--%>
<%--                    </button>--%>
                </div>
            </div>
            <div class="el-card__body">
                <table class="el-table">
    <thead>
    <tr>
        <th>茶叶名称</th>
        <th>数量</th>
<%--        <th>最小库存</th>--%>
<%--        <th>最大库存</th>--%>
        <th>生产时间</th>
        <th>保质期</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${inventoryList}" var="inventory">
        <tr>
            <c:forEach items="${teas}" var="tea">
                <c:if test="${inventory.tea_id==tea.tea_id}">
                    <td class="cell">${tea.tea_name}</td>
                </c:if>

            </c:forEach>
            
            <td class="cell">${inventory.quantity}</td>
<%--            <td class="cell">${inventory.min_stock}</td>--%>
<%--            <td class="cell">${inventory.max_stock}</td>--%>
            <td class="cell">${inventory.production_date}</td>
            <td class="cell">${inventory.shelf_life}</td>
            <td>

                <button class="el-button el-button--info" onclick="location.href='EditInventoryServlet?id=${inventory.inventory_id}'" style="padding: 5px 10px; font-size: 12px;">
                    <i class="fas fa-edit"></i> 修改
                </button>
                <button class="el-button el-button--danger" onclick="if(!confirm('确定要删除该库存记录吗？删除后不可恢复！')) return false;" style="padding: 5px 10px; font-size: 12px; margin-left: 5px;">
                    <i class="fas fa-trash"></i> 删除
                </button>
            </td>
        </tr>
    </c:forEach>
    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
</body>
</html>
